package com.ad.pet.common.data.utils;

import android.content.Intent;
import android.widget.TextView;

import com.blankj.utilcode.util.ClipboardUtils;

import java.util.UUID;

/**
 * Created by z on.
 * Des:聊天复制粘贴工具类
 * Date: 2017/5/23
 */

public class ChatClipboardUtil {

    public final static String ACTION_TEXT = "ACTION_TEXT";
    public final static String BODY_TEXT = "BODY_TEXT";
    public final static String HASHCODE = String.valueOf(UUID.randomUUID().toString().hashCode());

    /**
     * @param action 动作 目前只添加了 图片跟文本  见顶部常量
     * @param body   要复制的内容
     */
    public static void copy(String action, String body) {
        Intent intent = new Intent(action);
        intent.putExtra(BODY_TEXT, body);
        ClipboardUtils.copyIntent(intent);

    }

    /**
     * 粘贴
     *
     * @param editText 如果是文本会自动设置值到view
     */
    public static void paste(TextView editText) {
        Intent intent = ClipboardUtils.getIntent();
        String action = intent.getAction();
        String body = intent.getStringExtra(BODY_TEXT);
        switch (action) {
            case ACTION_TEXT:

                editText.setText(body);
                break;
        }
    }
}
